<!--
 * @Author: 朱安武 549410045@qq.com
 * @Date: 2023-01-09 15:40:43
 * @LastEditors: 朱安武 549410045@qq.com
 * @LastEditTime: 2023-01-09 16:46:56
 * @FilePath: \pinia-todo-setup\src\App.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <div>
    <TodoInput></TodoInput>
    <TodoFilter></TodoFilter>
    <TodoItem
      v-for="todo in filterList"
      :key="todo.id"
      :todo="todo"
    >
    </TodoItem>
  </div>
</template>
<script setup>
import { storeToRefs } from 'pinia'

import TodoInput from '@com/TodoInput.vue'
import TodoFilter from '@com/TodoFilter.vue'
import TodoItem from '@com/TodoItem.vue'

// 1. 导入 useTodoStore
import { useTodoStore  } from './stores/todo-store' 

// 2. 生成 store 对象
const todoStore = useTodoStore()

// 3. 使用 store
// storeToRefs 保持 store 的响应性
// 也可以直接使用 ：{{ todoStore.todoList }}
const { filterList } = storeToRefs(todoStore)
</script>